<template>
    <div class="header-con">
        <!-- 广告模块 -->
        <div class="header-advertising"
             v-show="showadver2">
            <a :href="toplink ">
                <div class="content-adv"
                     :class="[showadver==false ? 'add-hidden' :'' ]">
                    <el-image class="hotlist-img"
                              :src="topimgsrc"
                              fit="cover"></el-image>
                </div>
            </a>
            <div class="adver-i"
                 @click="closeadver()">
                <i class="el-icon-error addlcotion"></i>
            </div>

        </div>
        <!-- 头部内链 -->
        <transition name="fade">
            <div class="header-net">
                <div class="header-list">

                    <div class="header-link"
                         @click="Topage()">
                        <div class="icon-img">
                            <img class="content-img"
                                 src="../../assets/images/header-loge.png"
                                 alt="首页">
                        </div>
                    </div>
                    <div class="header-link"
                         v-for="(item, index) in headerlist"
                         :key="index"
                         :class="[item.id>10 ? 'addhiden':'']"
                         @click="ToMessageList(item.cate_id,item.listname)">
                        <el-link :href="item.link"
                                 target="_blank">{{ item.listname }}</el-link>
                    </div>

                    <div class="header-icon"
                         @click="showHide()"
                         :class="[netstuats==true ? 'addrotateX':'addrotateX2']">
                        <i class="el-icon-d-arrow-right"></i>
                    </div>
                </div>

                <div v-show="netstuats"
                     class="header-list">
                    <div class="header-link"
                         v-for="(item, index) in headerlist"
                         :key="index"
                         :class="[item.id<11 ? 'addhiden':'']"
                         @click="ToMessageList(item.cate_id,item.listname)">
                        <el-link :href="item.link"
                                 target="_blank">{{ item.listname }}</el-link>
                    </div>
                </div>

            </div>
        </transition>
        <!-- 日期/天气/农历/换肤/登录 -->
        <div class="header-login">
            <div class="showCalendar">
                <div class="Calendar_date">
                    <p class="type-size">{{ nowDate }} </p>
                </div>
                <div class="Calendar_weather">
                    <div class="icon-size"><img :src="weathericontoday"
                             alt="" /></div>
                    <p class="type-size">{{ weatype }} {{ weahigh }}~{{ wealow }} </p>
                </div>

                <div class="Calendar_pm">
                    <p class="type-size">空气指数:{{ weaaqi }}/ PM2.5:{{ weapm25 }} </p>
                </div>
                <div class="Calendar_city add-position">
                    <p class="type-size">
                        <span class="city-hidden"> {{ LocationCity }} </span>
                        <span class="city-hidden-2 changecity"
                              @click="choose">[切换]</span> </p>
                    <div v-if="show"
                         class="choose-area">
                        <region-picker class="add_location"
                                       two-select
                                       :province="province"
                                       :city="city"
                                       @onchange="change">
                        </region-picker>
                    </div>
                </div>

                <div class="Calendar_seven">
                    <el-dropdown class="type-size"
                                 placement="bottom">
                        <p> <span class="el-dropdown-link"> 一周天气查看<i class="el-icon-arrow-down el-icon--right"></i></span> </p>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item class="showweather">
                                <div class="s-children"
                                     v-for="(item, index) in weatherlist "
                                     :key="index">
                                    <div class="addlist">
                                        <p>{{ item.date }}</p>
                                    </div>
                                    <div class="addlist">
                                        <div class="icon-size-2 addstatue"><img :src="item.typeicon"
                                                 alt="" /></div>
                                    </div>
                                    <div class="addlist">
                                        <p>{{ item.highLow }}</p>
                                    </div>
                                    <div class="addlist">
                                        <p>{{ item.type }}</p>
                                    </div>
                                </div>
                            </el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
                <div class="Calendar_newdate">
                    <p><span>{{ nongli }} </span> </p>
                </div>
                <div class="Calendar_festvals">
                    <p class="type-size fes-hidden"><span class="add-css"> {{showfestvals}}</span></p>
                    <!-- <div class="icon-size-2"><img :src="showfestvalsicon"
                             alt="节日icon" /></div> -->
                </div>

                <div class="Calendar_login">
                    <p class="addmouse"
                       v-show="!userlogin"
                       @click="Tologin()">
                        <el-button type="info"
                                   plain> <span>登录 / 注册</span></el-button>
                    </p>

                    <el-dropdown v-show="userlogin"
                                 class="type-size"
                                 placement="bottom"
                                 @command="Topublic">
                        <el-button v-show="userlogin"
                                   type="success">{{loginname}}<i class="el-icon-caret-bottom el-icon--right"></i></el-button>

                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item v-for="(item,index) in userlist"
                                              :key="index"
                                              :command="item.link">{{item.name}}</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>

                <div class="Calendar_skin">
                    <themepicker></themepicker>
                </div>

            </div>
        </div>
    </div>
</template>
<script>
//import "../../ElementUI/tqw_widget_float.js";
import themepicker from "@/components/public/ThemePicker.vue";
import BMap from "BMap"; //引入百度地图定位
export default {

    data() {
        return {

            topimgsrc: require("../../assets/images/userimg.jpg"),
            toplink: "",
            showadver: true,
            showadver2: true,
            netstuats: false,
            headerlist: [
                { id: 0, listname: "企业需求", link: "/SkinPeeler" },
                { id: 1, listname: "知识论坛", link: "" },
                { id: 2, listname: "品牌代理", link: "" },
                { id: 3, listname: "原材供应", link: "" },
                { id: 4, listname: "生产加工", link: "" },
                { id: 5, listname: "新品代销", link: "" },
                { id: 6, listname: "产品定购", link: "" },
                { id: 7, listname: "物流调度", link: "" },
                { id: 8, listname: "商务合作", link: "" },
                { id: 9, listname: "投资企业", link: "" },
                { id: 10, listname: "法律顾问", link: "" },
                { id: 11, listname: "项目扩展", link: "" },
                { id: 12, listname: "股份增转", link: "" },
                { id: 13, listname: "商业合并", link: "" },
                { id: 14, listname: "资产核算", link: "" },
                { id: 15, listname: "战略合作", link: "" },
                { id: 16, listname: "海外服务", link: "" },
                { id: 17, listname: "项目竞标", link: "" },
                { id: 18, listname: "公益中心", link: "" },
                { id: 19, listname: "网站合作", link: "" },
                { id: 20, listname: "会员专栏", link: "" },
                { id: 21, listname: "网站基金", link: "" },
                //{ id: 22, listname: "法律顾问", link: "" },
                // { id: 23, listname: "法律顾问", link: "" },
                // { id: 24, listname: "法律顾问", link: "" },
                // { id: 25, listname: "法律顾问", link: "" },
                // { id: 26, listname: "法律顾问", link: "" },
                // { id: 27, listname: "法律顾问", link: "" },
                // { id: 28, listname: "法律顾问", link: "" },
                // { id: 29, listname: "法律顾问", link: "" },
            ],
            //时间农历部分
            nowDate: "", //当日时间和星期
            nongli: "",//显示农历
            Festivals: [
                // {
                //     id: 0,
                //     name: "春节",
                //     festdate: "正月初一",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 1,
                //     name: "元宵节",
                //     festdate: "正月十五",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 2,
                //     name: "清明节",
                //     festdate: "4月4.5.6日",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 3,
                //     name: "端午节",
                //     festdate: "五月初五",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 4,
                //     name: "七夕节",
                //     festdate: "七月初七",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 5,
                //     name: "中秋节",
                //     festdate: "八月十五",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 6,
                //     name: "重阳节",
                //     festdate: "九月初九",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 7,
                //     name: "冬至",
                //     festdate: "公历12月21或22或23日",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 8,
                //     name: "除夕",
                //     festdate: "十二月二十九或三十日",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
                // {
                //     id: 9,
                //     name: "今天",
                //     festdate: "三月十九",
                //     imgSrc: require("../../assets/images/duanwu.jpg")
                // },
            ],
            showfestvals: "",
            showfestvalsicon: "",
            //天气部分
            weatype: "",//天气类型
            weahigh: "",//最高温度
            wealow: "",//最低温度
            weaaqi: "",//空气指数
            weapm25: "", //PM2.5
            weatherlist: [],//七日天气列表
            weathericontoday: "http://open.itboy.net/images/tianqi/unknown.png",//默认天气图标
            weathericon: "http://open.itboy.net/images/tianqi/unknown.png", //未知天气类型
            typeicon: [
                {
                    id: 0,
                    name: "晴",
                    icon: "http://open.itboy.net/images/tianqi/fine.png"
                },
                {
                    id: 1,
                    name: "多云",
                    icon: "http://open.itboy.net/images/tianqi/cloud.png"
                },

                {
                    id: 2,
                    name: "阴",
                    icon: "http://open.itboy.net/images/tianqi/overcast.png"
                },
                {
                    id: 3,
                    name: "小雨",
                    icon: "http://open.itboy.net/images/tianqi/small_rain.png"
                },
                {
                    id: 4,
                    name: "小到中雨",
                    icon: "http://open.itboy.net/images/tianqi/stom_rain.png"
                },
                {
                    id: 5,
                    name: "阵雨",
                    icon: "http://open.itboy.net/images/tianqi/quick_rain.png"
                },
                {
                    id: 6,
                    name: "雷阵雨",
                    icon: "http://open.itboy.net/images/tianqi/lquick_rain.png"
                },
                {
                    id: 7,
                    name: "中雨",
                    icon: "http://open.itboy.net/images/tianqi/mid_rain.png"
                },
                {
                    id: 8,
                    name: "中到大雨",
                    icon: "http://open.itboy.net/images/tianqi/big_rain.png"
                },
                {
                    id: 9,
                    name: "大雨",
                    icon: "http://open.itboy.net/images/tianqi/big_rain.png"
                },
                {
                    id: 10,
                    name: "大到暴雨",
                    icon: "http://open.itboy.net/images/tianqi/mbig_rain.png"
                },
                {
                    id: 11,
                    name: "暴雨",
                    icon: "http://open.itboy.net/images/tianqi/mbig_rain.png"
                },
                {
                    id: 12,
                    name: "暴雨到大暴雨",
                    icon: "http://open.itboy.net/images/tianqi/mbig_rain.png"
                },
                {
                    id: 13,
                    name: "大暴雨",
                    icon: "http://open.itboy.net/images/tianqi/mbig_rain.png"
                },
                {
                    id: 14,
                    name: "大暴雨到特大暴雨",
                    icon: "http://open.itboy.net/images/tianqi/mbig_rain.png"
                },
                {
                    id: 15,
                    name: "特大暴雨",
                    icon: "http://open.itboy.net/images/tianqi/mbig_rain.png"
                },
                {
                    id: 16,
                    name: "雨夹雪",
                    icon: "http://open.itboy.net/images/tianqi/rain_snow.png"
                },
                {
                    id: 17,
                    name: "阵雪",
                    icon: "http://open.itboy.net/images/tianqi/quick_snow.png"
                },
                {
                    id: 18,
                    name: "冻雨",
                    icon: "http://open.itboy.net/images/tianqi/ice_rain.png"
                },
                {
                    id: 19,
                    name: "雷阵雨伴有冰雹",
                    icon: "http://open.itboy.net/images/tianqi/quick_rain_ice.png"
                },
                {
                    id: 20,
                    name: "雾",
                    icon: "http://open.itboy.net/images/tianqi/fog.png"
                },
                {
                    id: 21,
                    name: "雾霾",
                    icon: "http://open.itboy.net/images/tianqi/sand.png"
                },
                {
                    id: 22,
                    name: "浮尘",
                    icon: "http://open.itboy.net/images/tianqi/sand.png"
                },
                {
                    id: 23,
                    name: "扬沙",
                    icon: "http://open.itboy.net/images/tianqi/sand.png"
                },
                {
                    id: 24,
                    name: "沙尘暴",
                    icon: "http://open.itboy.net/images/tianqi/sand.png"
                },
                {
                    id: 25,
                    name: "强沙尘暴",
                    icon: "http://open.itboy.net/images/tianqi/sand.png"
                },
                {
                    id: 26,
                    name: "未知天气类型",
                    icon: "http://open.itboy.net/images/tianqi/unknown.png"
                }
            ],
            //切换城市
            province: "云南", // you can set initial value or not.
            city: 440100, // by code or name.
            district: "",
            LocationCity: "正在定位",
            show: false, //给渲染层定义一个初始值
            Peeling: [
                {
                    id: 0,
                    name: "淡蓝",
                    icon: require("../../assets/images/danlan.png")
                },
                {
                    id: 2,
                    name: "灰蓝",
                    icon: require("../../assets/images/huilan.png")
                }
            ],
            userlogin: false,//用户登录状态 判断换肤是否显示
            loginname: "",
            loginId: "",
            userlist: [
                {
                    id: 0,
                    name: "我的发布",
                    link: "/Mypublish"
                },
                {
                    id: 1,
                    name: "发布文章",
                    link: "/PostMessage"
                },
                {
                    id: 2,
                    name: "余额充值",
                    link: "/Balance"
                },
                {
                    id: 3,
                    name: "修改密码",
                    link: "/ChangePassword"
                },
                {
                    id: 4,
                    name: "退出登录",
                    link: "/"
                },
            ],

        };

    },
    components: {
        themepicker
    },
    created() {

        //读取sessionStorage的ID
        let seeToken = localStorage.getItem('accessName')
        let accessId = localStorage.getItem('accessId')

        
        if (seeToken != null) {
            this.userlogin = true
            this.loginname = seeToken
            if (accessId != null) {
                this.loginId = accessId
            }
            else {
                this.userlogin = false
            }
        }
        else {
            this.userlogin = false
        }

        //确定当前日期
        this.setNowTimes();
        //转换农历日期
        this.lunarCalendar();
        //触发城市定位
        this.locationCity();

        //广告链接
        this.getadLinks();
        //头部链接
        this.getHeaderLink();


    },
    mounted() {

    },
    methods: {
        //判定
        closeadver() {
            this.showadver = !this.showadver

            this.timer = setTimeout(() => {
                this.showadver2 = !this.showadver2
            }, 300)

        },
        //显示列表隐藏
        //点击展开收起
        showHide(i) {
            let _this = this;
            let listlength = _this.headerlist.length;
            _this.netstuats = !_this.netstuats
        },

        //日历星期显示
        setNowTimes() {
            let myDate = new Date();

            let wk = myDate.getDay();
            let yy = String(myDate.getFullYear());
            let mm = myDate.getMonth() + 1;
            let dd = String(
                myDate.getDate() < 10 ? "0" + myDate.getDate() : myDate.getDate()
            );
            let hou = String(
                myDate.getHours() < 10 ? "0" + myDate.getHours() : myDate.getHours()
            );
            let min = String(
                myDate.getMinutes() < 10
                    ? "0" + myDate.getMinutes()
                    : myDate.getMinutes()
            );
            let sec = String(
                myDate.getSeconds() < 10
                    ? "0" + myDate.getSeconds()
                    : myDate.getSeconds()
            );
            let weeks = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
            let week = weeks[wk];
            this.nowDate = mm + "月" + dd + "日" + week;
        },
        //转换农历日期
        lunarCalendar() {
            var CalendarData = new Array(100);
            var madd = new Array(12);
            var tgString = "甲乙丙丁戊己庚辛壬癸";
            var dzString = "子丑寅卯辰巳午未申酉戌亥";
            var numString = "一二三四五六七八九十";
            var monString = "正二三四五六七八九十冬腊";
            var weekString = "日一二三四五六";
            var sx = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
            var cYear, cMonth, cDay, TheDate;
            CalendarData = new Array(
                0xa4b, 0x5164b, 0x6a5, 0x6d4, 0x415b5, 0x2b6, 0x957, 0x2092f, 0x497, 0x60c96, 0xd4a, 0xea5, 0x50da9, 0x5ad, 0x2b6, 0x3126e, 0x92e,
                0x7192d, 0xc95, 0xd4a, 0x61b4a, 0xb55, 0x56a, 0x4155b, 0x25d, 0x92d, 0x2192b, 0xa95, 0x71695, 0x6ca, 0xb55, 0x50ab5, 0x4da, 0xa5b,
                0x30a57, 0x52b, 0x8152a, 0xe95, 0x6aa, 0x615aa, 0xab5, 0x4b6, 0x414ae, 0xa57, 0x526, 0x31d26, 0xd95, 0x70b55, 0x56a, 0x96d, 0x5095d,
                0x4ad, 0xa4d, 0x41a4d, 0xd25, 0x81aa5, 0xb54, 0xb6a, 0x612da, 0x95b, 0x49b, 0x41497, 0xa4b, 0xa164b, 0x6a5, 0x6d4, 0x615b4, 0xab6, 0x957,
                0x5092f, 0x497, 0x64b, 0x30d4a, 0xea5, 0x80d65, 0x5ac, 0xab6, 0x5126d, 0x92e, 0xc96, 0x41a95, 0xd4a, 0xda5, 0x20b55, 0x56a, 0x7155b,
                0x25d, 0x92d, 0x5192b, 0xa95, 0xb4a, 0x416aa, 0xad5, 0x90ab5, 0x4ba, 0xa5b, 0x60a57, 0x52b, 0xa93, 0x40e95
            );
            madd[0] = 0; madd[1] = 31; madd[2] = 59; madd[3] = 90; madd[4] = 120; madd[5] = 151;
            madd[6] = 181; madd[7] = 212; madd[8] = 243; madd[9] = 273; madd[10] = 304; madd[11] = 334;
            function GetBit(m, n) { return (m >> n) & 1; }
            function e2c() {
                TheDate =
                    arguments.length != 3
                        ? new Date()
                        : new Date(arguments[0], arguments[1], arguments[2]);
                var total, m, n, k;
                var isEnd = false;
                var tmp = TheDate.getYear();

                if (tmp < 1900) {
                    tmp += 1900;
                }
                total =
                    (tmp - 1921) * 365 +
                    Math.floor((tmp - 1921) / 4) +
                    madd[TheDate.getMonth()] +
                    TheDate.getDate() -
                    38;

                if (TheDate.getYear() % 4 == 0 && TheDate.getMonth() > 1) {
                    total++;
                }

                for (m = 0; ; m++) {
                    k = CalendarData[m] < 0xfff ? 11 : 12;
                    for (n = k; n >= 0; n--) {
                        if (total <= 29 + GetBit(CalendarData[m], n)) {
                            isEnd = true;
                            break;
                        }
                        total = total - 29 - GetBit(CalendarData[m], n);
                    }
                    if (isEnd) break;
                }

                cYear = 1921 + m;
                cMonth = k - n + 1;
                cDay = total;

                if (k == 12) {
                    if (cMonth == Math.floor(CalendarData[m] / 0x10000) + 1) {
                        cMonth = 1 - cMonth;
                    }
                    if (cMonth > Math.floor(CalendarData[m] / 0x10000) + 1) {
                        cMonth--;
                    }
                }
            }
            function GetcDateString() {
                var tmp = "";
                tmp += tgString.charAt((cYear - 4) % 10);
                tmp += dzString.charAt((cYear - 4) % 12);
                tmp += "(";
                tmp += sx.charAt((cYear - 4) % 12);
                tmp += ")年 ";

                if (cMonth < 1) {
                    tmp += "(闰)";
                    tmp += monString.charAt(-cMonth - 1);
                } else {
                    tmp += monString.charAt(cMonth - 1);
                }

                tmp += "月";
                tmp += cDay < 11 ? "初" : cDay < 20 ? "十" : cDay < 30 ? "廿" : "三十";
                if (cDay % 10 != 0 || cDay == 10) {
                    tmp += numString.charAt((cDay - 1) % 10);
                }
                return tmp;
            }
            function GetLunarDay(solarYear, solarMonth, solarDay) {
                if (solarYear < 1921 || solarYear > 2020) {
                    return "";
                } else {
                    solarMonth = parseInt(solarMonth) > 0 ? solarMonth - 1 : 11;
                    e2c(solarYear, solarMonth, solarDay);
                    return GetcDateString();
                }
            }
            var D = new Date();
            var yy = D.getFullYear();
            var mm = D.getMonth() + 1;
            var dd = D.getDate();
            var ww = D.getDay();
            var ss = parseInt(D.getTime() / 1000);
            if (yy < 100) yy = "19" + yy;

            function showCal() {
                let nonglitime;
                if (yy > 2020) {
                    yy = yy - 19;

                    nonglitime = GetLunarDay(yy, mm, dd);
                }
                else {
                    nonglitime = GetLunarDay(yy, mm, dd);
                }


                return nonglitime;
            }
            this.nongli = "农历：" + showCal().split(/\s+/)[1];;
            let changefes = showCal().split(/\s+/)[1];

            //传统节日处理
            for (var i = 0; i < this.Festivals.length; i++) {

                if (this.Festivals[i].festdate == changefes) {
                    this.showfestvals = this.Festivals[i].name;
                    this.showfestvalsicon = this.Festivals[i].imgSrc;

                }
            }

        },
        //城市定位
        locationCity() {
            var _this = this;
            //读取缓存
            if (sessionStorage.getItem("LocationCity")) {
                //上面这个就是去到详情页或者编辑页的标识// 
                //如果有这个就读取缓存里面的数据
                _this.LocationCity = sessionStorage.getItem("LocationCity");
                let p = sessionStorage.getItem("LocationPro");
                let c = sessionStorage.getItem("LocationCity");
                _this.getWeather(p, c, 1);

            }
            //没有则执行定位方法
            else {
                //定义获取城市方法
                const geolocation = new BMap.Geolocation();

                geolocation.getCurrentPosition(
                    function getinfo(position) {
                        let addcity = position.address.city; //获取城市信息
                        let addprovince = position.address.province; //获取省份信息
                        //省份 城市格式处理
                        let p = _this.optimizeP(addprovince);
                        let c = _this.optimizeC(p, addcity);

                        _this.LocationCity = addcity.split("市")[0];
                        sessionStorage.setItem("LocationPro", p);
                        sessionStorage.setItem("LocationCity", _this.LocationCity);

                        _this.getWeather(p, c, 1);

                    },
                    function (e) {
                        _this.LocationCity = "定位失败";
                    },
                    { provider: "baidu" }
                );
            }

        },
        //请求天气接口weather
        getWeather(province, city, num) {

            var _this = this;
            //读取缓存

            if (num == 1) {
                if (sessionStorage.getItem("weatype")) {
                    //上面这个就是去到详情页或者编辑页的标识// 
                    //如果有这个就读取缓存里面的数据
                    _this.weatype = sessionStorage.getItem("weatype");
                    _this.weathericontoday = sessionStorage.getItem("weathericontoday");
                    _this.weahigh = sessionStorage.getItem("weahigh");
                    _this.wealow = sessionStorage.getItem("wealow");
                    _this.weaaqi = sessionStorage.getItem("weaaqi");
                    _this.weapm25 = sessionStorage.getItem("weapm25");
                    _this.weatherlist = JSON.parse(sessionStorage.getItem("weatherlist"));

                }
                //没有则执行定位方法
                else {
                    let Url = "/adm?pname=" + province + "&cname=" + city;
                    let Params = {};

                    this.$https.fetchGet(Url, Params).then(res => {
                        let resdata = res.data;
                        switch (resdata.code) {
                            case 1000:
                                let data = JSON.parse(resdata.data)
                                switch (data.status) {
                                    case 200:
                                        _this.weatype = data.data.forecast[0].type;
                                        sessionStorage.setItem("weatype", _this.weatype)
                                        for (var j = 0; j < _this.typeicon.length; j++) {
                                            if (_this.typeicon[j].name == _this.weatype) {
                                                _this.weathericontoday = _this.typeicon[j].icon;
                                                sessionStorage.setItem("weathericontoday", _this.weathericontoday)

                                            }
                                        }

                                        _this.weahigh = data.data.forecast[0].high.split("高温")[1];
                                        _this.wealow = data.data.forecast[0].low.split("低温")[1];
                                        _this.weaaqi = data.data.forecast[0].aqi;
                                        _this.weapm25 = data.data.pm25;


                                        sessionStorage.setItem("weahigh", _this.weahigh)
                                        sessionStorage.setItem("wealow", _this.wealow)
                                        sessionStorage.setItem("weaaqi", _this.weaaqi)
                                        sessionStorage.setItem("weapm25", _this.weapm25)


                                        this.weatherlist = [];
                                        for (var i = 0; i < 7; i++) {
                                            let forecast = data.data.forecast;
                                            let adddate = forecast[i].ymd.split("-");
                                            let addmonth = adddate[1].split("0");

                                            for (var k = 0; k < this.typeicon.length; k++) {
                                                if (_this.typeicon[k].name == forecast[i].type) {
                                                    _this.weathericon = _this.typeicon[k].icon;

                                                }
                                            }

                                            _this.weatherlist.push({
                                                date: addmonth[1] + "月" + forecast[i].date + "号",
                                                //date: forecast[i].ymd,
                                                week: forecast[i].week,
                                                typeicon: _this.weathericon,
                                                highLow:
                                                    forecast[i].low.split("低温")[1] +
                                                    "~" +
                                                    forecast[i].high.split("高温")[1],
                                                type: forecast[i].type
                                            });

                                            sessionStorage.setItem("weatherlist", JSON.stringify(_this.weatherlist))
                                        }

                                        break;
                                }
                                break;
                            case 1002:
                                
                                break

                        }
                    });
                }
            }
            else {
                let Url = "/adm?pname=" + province + "&cname=" + city;
                let Params = {};

                this.$https.fetchGet(Url, Params).then(res => {
                    let resdata = res.data;
                    switch (resdata.code) {
                        case 1000:
                            let data = JSON.parse(resdata.data)
                            switch (data.status) {
                                case 200:
                                    _this.weatype = data.data.forecast[0].type;
                                    sessionStorage.setItem("weatype", _this.weatype)
                                    for (var j = 0; j < _this.typeicon.length; j++) {
                                        if (_this.typeicon[j].name == _this.weatype) {
                                            _this.weathericontoday = _this.typeicon[j].icon;
                                            sessionStorage.setItem("weathericontoday", _this.weathericontoday)

                                        }
                                    }

                                    _this.weahigh = data.data.forecast[0].high.split("高温")[1];
                                    _this.wealow = data.data.forecast[0].low.split("低温")[1];
                                    _this.weaaqi = data.data.forecast[0].aqi;
                                    _this.weapm25 = data.data.pm25;


                                    sessionStorage.setItem("weahigh", _this.weahigh)
                                    sessionStorage.setItem("wealow", _this.wealow)
                                    sessionStorage.setItem("weaaqi", _this.weaaqi)
                                    sessionStorage.setItem("weapm25", _this.weapm25)


                                    this.weatherlist = [];
                                    for (var i = 0; i < 7; i++) {
                                        let forecast = data.data.forecast;
                                        let adddate = forecast[i].ymd.split("-");
                                        let addmonth = adddate[1].split("0");

                                        for (var k = 0; k < this.typeicon.length; k++) {
                                            if (_this.typeicon[k].name == forecast[i].type) {
                                                _this.weathericon = _this.typeicon[k].icon;

                                            }
                                        }

                                        _this.weatherlist.push({
                                            date: addmonth[1] + "月" + forecast[i].date + "号",
                                            //date: forecast[i].ymd,
                                            week: forecast[i].week,
                                            typeicon: _this.weathericon,
                                            highLow:
                                                forecast[i].low.split("低温")[1] +
                                                "~" +
                                                forecast[i].high.split("高温")[1],
                                            type: forecast[i].type
                                        });

                                        sessionStorage.setItem("weatherlist", JSON.stringify(_this.weatherlist))
                                    }

                                    break;
                            }
                            break;
                        case 1002:
                            
                            break

                    }
                });

            }

        },

        //广告链接
        getadLinks() {
            let _this = this;
            let Url = "/adv"
            let Params = {};
            this.$https.fetchGet(Url, Params).then(res => {
                let resdata = res.data;
                switch (resdata.code) {
                    case 1000:


                        let adddata = resdata.data
                        for (let i = 0; i < adddata.length; i++) {
                            if (adddata[i].pos == 1) {
                                _this.topimgsrc = adddata[i].pic;
                                _this.toplink = adddata[i].link

                            }
                        }
                        break;
                    case 1002:
                        console.log(resdata.msg)
                        break
                }
            });
        },
        //获取头部链接接口
        getHeaderLink() {
            let _this = this;
            _this.headerlist = [];
            let Url = "/darticlecate?page=1&limit=100"
            let Params = {};
            this.$https.fetchGet(Url, Params).then(res => {
                let resdata = res.data;
                switch (resdata.code) {
                    case 1000:
                        let adddata = resdata.data
                        switch (adddata.current_page) {
                            case 1:
                                let puredata = adddata.data;
                                for (var i = 0; i < puredata.length; i++) {
                                    _this.headerlist.push({
                                        id: i,
                                        listname: puredata[i].cate_name,
                                        link: puredata[i].link,
                                        cate_id: puredata[i].id,
                                    });
                                }
                                break;
                        }
                        break;
                    case 1002:
                        console.log(resdata.msg)
                        break
                }

            });
        },

        //获取切换城市信息
        change(value) {
            let _this = this;

            if (value.city != undefined) {
                if (value.province != "请选择") {
                    let p = _this.optimizeP(value.province);
                    sessionStorage.setItem("LocationPro", p);
                    let c;
                    if (p == "北京" || p == "上海" || p == "天津" || p == "香港" || p == "澳门" || p == "重庆") {
                        c = "";
                        _this.LocationCity = p;
                        _this.show = false;
                    } else {
                        if (value.city != "请选择") {
                            c = _this.optimizeC(p, value.city);
                            // this.weacity = data.cityInfo.city.split("市")[0];
                            _this.LocationCity = value.city.split("市")[0];
                            _this.show = false;
                        }
                    }
                     sessionStorage.setItem("LocationCity", _this.LocationCity);
                    _this.getWeather(p, c);
                }
            }


        },
        //点击判断城市切换div的状态
        choose() {
            this.show = !this.show;
        },

        //省份格式处理
        optimizeP(p) {
            let province;

            province = p.substring(0, 2);


            return province;
        },
        //城市格式处理
        optimizeC(p, c) {
            let newcity;
            if (p == "北京" || p == "上海" || p == "天津" || p == "香港" || p == "澳门" || p == "重庆") {
                newcity = "";

            }
            else {
                newcity = c.substring(0, 2);

            }

            return newcity;
        },
        //登录跳转
        Tologin() {
            this.$router.push({ path: "/Login" });
        },
        //个人中心跳转
        Topublic(command) {
            
            if (command == "/") {
                localStorage.clear()
                this.userlogin = false
            }
            this.$router.push(command)
        },
        //点击头部选项

        //精推热点分类跳转
        ToMessageList(listId, listname) {

            sessionStorage.setItem('Detailslist', listId)
            this.$bus.$emit('change', listId)
            this.$bus.$emit('changename', listname)

            this.$router.push({
                path: '/MessageList',
                // name: 'MessageList',
                // params: {
                //     name: this.hotname,
                //     id: listId
                // }
                query: {
                    name: listname,
                    id: listId
                }
            })
        },

        //跳转首页
        Topage() {
            this.$router.push("/")
        }

    },
    beforeDestroy() {
        clearInterval(this.timer);
        this.timer = null;
    }
};
</script>
<style lang="scss" >
@import '../../assets/css/theme';
@import '../../assets/css/tqw_widget_float.css';

.header-con {
    width: 100%;
    min-width: 1000px;
    height: auto;
    background: #ffffff;
    .header-advertising {
        width: 100%;
        height: 55px;
        float: left;
        background: #ffffff;
        position: relative;
        cursor: pointer;
        .content-adv {
            width: 100%;
            height: 55px;
            // background-image: url(../../assets/images/header-adv.png);
            background-position: left top;
            background-repeat: no-repeat;
            background-size: 100% 100%;
            .hotlist-img {
                width: 100%;
                height: 100%;
            }
            .add-hidden {
                transform: translate(0, -55px);
                transition: transform 0.3s ease 0s;
            }
        }
        .adver-i {
            width: 25px;
            height: 25px;
            float: right;
            position: absolute;
            top: 0px;
            right: 0px;
            text-align: right;
            line-height: 25px;
            z-index: 100;
            font-size: 20px;
            cursor: pointer;
            .addlcotion {
                width: 25px;
                height: 25px;
            }
        }
    }
    .header-net {
        width: 100%;
        min-width: 1000px;
        height: auto;
        margin: 0 auto;
        background: #ffffff;
        font-size: 15px;
        float: left;
        padding: 10px 92px 10px 92px;
        position: relative;
        .header-list {
            max-width: 1200px;
            width: 100%;
            min-width: 1000px;
            height: 100%;
            margin: 0 auto;
            text-align: center;
            overflow: hidden;
            position: relative;
            .header-link {
                width: 8%;
                height: 33px;
                float: left;
                font-weight: 400;
                letter-spacing: 1px;
                line-height: 33px;
                color: #333333;
                .icon-img {
                    width: 100%;
                    height: 33px;
                    cursor: pointer;
                    .content-img {
                        width: 100%;
                        height: 100%;
                    }
                }
                .el-link.el-link--default {
                    //color: #ff6f64;
                    color: #333333;
                }
                .el-link.el-link--default:hover {
                    color: #558ff8;
                }
                .el-link--inner:hover {
                    color: #558ff8;
                }
            }
            .header-icon {
                height: 25px;
                width: 25px;
                margin-top: 2px;
                float: left;
                color: #333333;
                line-height: 33px;
                font-size: 18px;
                cursor: pointer;
                padding-left: 8px;
            }
        }
        .fade-enter {
            opacity: 0;
            height: 0;
        }
        .fade-enter-active {
            transition: height 1.5s;
        }
        .fade-leave-to {
            opacity: 0;
            height: 0;
        }
        .fade-leave-active {
            transition: height 1s;
        }
    }

    .header-login {
        width: 100%;
        min-width: 1000px;
        height: 46px;
        font-size: 13px;
        padding: 0px 92px 0px 92px;
        border-top: 1px solid #e5e6e9;
        border-bottom: 1px solid #e5e6e9;
        background: #ffffff;
        float: left;
        .showCalendar {
            max-width: 1200px;
            width: 100%;
            min-width: 1000px;
            height: 100%;
            margin: 0 auto;
            line-height: 46px;
            font-size: 13px;
            font-weight: 400;
            color: #666666;
            letter-spacing: 1px;
            text-align: center;

            .Calendar_date {
                width: 97px;
                height: 36px;
                float: left;
            }
            .Calendar_weather {
                width: 150px;
                height: 36px;
                float: left;
            }
            .Calendar_pm {
                width: 170px;
                height: 36px;
                float: left;
            }
            .Calendar_city {
                width: 115px;
                height: 36px;
                float: left;
                padding-left: 10px;
                text-align: center;
            }
            .Calendar_seven {
                width: 125px;
                height: 36px;
                float: left;
            }
            .Calendar_newdate {
                width: 120px;
                height: 36px;
                float: left;
            }
            .Calendar_festvals {
                width: 10px;
                height: 36px;
                float: left;
            }
            .Calendar_skin {
                width: 85px;
                height: 36px;
                float: right;
            }
            .Calendar_login {
                width: 100px;
                height: 36px;
                float: right;
                margin-right: 15px;
            }
            .city-hidden {
                display: block;
                max-width: 60px;
                height: 36px;
                overflow: hidden;
                float: left;
                text-align: center;
            }
            .city-hidden-2 {
                display: block;
                width: 40px;
                height: 36px;
                overflow: hidden;
                float: left;
            }
            .fes-hidden {
                display: block;
                max-width: 60px;
                height: 36px;
                overflow: hidden;
                float: left;
                margin-top: 1px;
                margin-left: 15px;
                margin-right: 10px;
            }
            .add-position {
                position: relative;
                .choose-area {
                    width: 400px;
                    height: 200px;
                    position: absolute;
                    left: 40px;
                    top: 30px;
                    .add_location {
                        float: left;
                    }
                }
            }
            .addmouse {
                cursor: pointer;
            }
            .addcolor {
                color: #558ff8;
            }
            .add-css {
                width: auto;
                height: 36px;
                font-weight: 600;
                color: #000;
            }
        }
    }
}

.header-list-he-2 {
    height: 83px;
}
.header-list-he-3 {
    height: 116px;
}

.el-link.el-link--default {
    color: #ff6f64;
}

.showweather {
    width: 700px;
    height: 200px;
    float: left;
    .s-children {
        width: 100px;
        height: 200px;
        float: left;
        .addlist {
            width: 100%;
            height: 20%;
            float: left;
            text-align: center;
        }
    }
}

.icon-size {
    width: 20px;
    height: 100%;
    float: left;
    padding-top: 4px;
}
.icon-size-2 {
    width: 20px;
    height: 100%;
    float: left;
    padding-top: 6px;
}
.icon-size img {
    width: 20px;
    height: 20px;
}
.icon-size-2 img {
    width: 20px;
    height: 20px;
}
.type-size {
    text-align: center;
    cursor: pointer;
}

.addstatue {
    margin-left: 42%;
}
.changecity {
    cursor: pointer;
}
.changecity :hover {
    color: blue($color: #000000);
}

.addhiden {
    display: none;
}
.addrotateX {
    transform: rotate(90deg);

    transition: transform 0.5s ease 0s;
}
.addrotateX2 {
    transform: rotate(0deg);
    transition: transform 0.5s ease 0s;
}
</style>

